////////////////////////////////////////////////
//FILE:         VideoPlay.h               //
//DATE:         2014-06-23                    //
//VERSION:      4.3.1                           //
//DESCRIPTION:  Interface For VideoPlay.lib //
//COPYRIGHT:    zw                     //
////////////////////////////////////////////////
#define _WINDLL

#ifndef __VIDEOPLAY_H__
#define __VIDEOPLAY_H__

#if defined( _WINDLL)
	#define VideoPlay_API extern "C" __declspec(dllexport)
#else
	#define VideoPlay_API extern "C" __declspec(dllimport)
#endif

#define VideoPlay_MAX_SUPPORTS 64

#define  VideoPlay_NOERROR					0	
#define	 VideoPlay_PARA_OVER				    1	
#define  VideoPlay_ORDER_ERROR				2	
#define  VideoPlay_NOT_SUPPORT             	3
#define  VideoPlay_DEC_VIDEO_ERROR			4	
#define  VideoPlay_DEC_AUDIO_ERROR			5	
#define	 VideoPlay_ALLOC_MEMORY_ERROR		    6	
#define  VideoPlay_OPEN_FILE_ERROR			7	
#define  VideoPlay_SUPPORT_OPEN_ONLY		    8	
#define  VideoPlay_CREATE_DDRAW_ERROR		    9	
#define  VideoPlay_CREATE_OFFSCREEN_ERROR    10	
#define  VideoPlay_BUF_OVER			       11	
#define  VideoPlay_CREATE_SOUND_ERROR	       12	
#define	 VideoPlay_SET_VOLUME_ERROR	       13	
#define  VideoPlay_SUPPORT_FILE_ONLY	       14	
#define  VideoPlay_SUPPORT_STREAM_ONLY	   15	
#define  VideoPlay_SYS_NOT_SUPPORT		   16	
#define  VideoPlay_FILEHEADER_UNKNOWN        17	
#define  VideoPlay_VERSION_INCORRECT	       18	
#define  VideoPlay_INIT_DECODER_ERROR        19	
#define  VideoPlay_CHECK_FILE_ERROR	       20	
#define  VideoPlay_SUPPORT_FILESTREAM_ONLY   21
#define	 VideoPlay_BLT_ERROR			       22	
#define  VideoPlay_UPDATE_ERROR		       23	

#define MAX_DISPLAY_WND   4

//Display type
#define DISPLAY_NORMAL  1
#define DISPLAY_QUARTER 2

#define SUPPORT_DDRAW		1 
#define SUPPORT_BLT         2 
#define SUPPORT_BLTFOURCC   4 
#define SUPPORT_BLTSHRINKX  8 
#define SUPPORT_BLTSHRINKY  16 
#define SUPPORT_BLTSTRETCHX 32 
#define SUPPORT_BLTSTRETCHY 64 
#define SUPPORT_SSE         128 
#define SUPPORT_MMX			256 

#define MAX_DIS_FRAMES 50
#define MIN_DIS_FRAMES 6

#define BY_FRAMENUM  1
#define BY_FRAMETIME 2

#define SOURCE_BUF_MAX	2048 * 1000 * 4
#define SOURCE_BUF_MIN	1024*50

#define STREAME_REALTIME 0
#define STREAME_FILE	 1

#define T_AUDIO16	101
#define T_UYVY		1
#define T_YV12		3
#define T_RGB32		7

typedef struct 
{
	long nFrameNum;          
	UINT nFrameTime;          
	ULONG nFilePos;            
}FRAME_POS ,*PFRAME_POS;

typedef struct{
	long nWidth;
	long nHeight;
	long nStamp;
	long nType;
	long nFrameRate;
}FRAME_INFO;

typedef struct{
	char *pDataBuf; //数据帧首地址
	long nSize;		//数据帧的大小
	long nFrameNum; //数据帧的个数
	BOOL bIsAudio;	//是否音频帧
	long nReserved; //保留
}FRAME_TYPE;

//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//API

VideoPlay_API BOOL __stdcall VideoPlay_UnlockPort(LONG nPort);

VideoPlay_API BOOL __stdcall VideoPlay_LockNewPort(LONG* pdwPort);

VideoPlay_API BOOL __stdcall VideoPlay_InitDDraw(HWND hWnd);

VideoPlay_API BOOL __stdcall VideoPlay_RealeseDDraw();

VideoPlay_API BOOL __stdcall VideoPlay_OpenFile(LONG nPort,LPSTR sFileName);

VideoPlay_API BOOL __stdcall VideoPlay_OpenFileEx(LONG nPort,LPSTR sFileName, int iMaxImageWidth, int iMaxImageHeight);

VideoPlay_API BOOL __stdcall VideoPlay_CloseFile(LONG nPort);

VideoPlay_API BOOL __stdcall VideoPlay_Play(LONG nPort, HWND hWnd);

VideoPlay_API BOOL __stdcall VideoPlay_Stop(LONG nPort);

VideoPlay_API BOOL __stdcall VideoPlay_Pause(LONG nPort,DWORD nPause);

VideoPlay_API BOOL __stdcall VideoPlay_Fast(LONG nPort);

VideoPlay_API BOOL __stdcall VideoPlay_Slow(LONG nPort);

VideoPlay_API BOOL __stdcall VideoPlay_OneByOne(LONG nPort);

VideoPlay_API BOOL __stdcall VideoPlay_SetPlayPos(LONG nPort,float fRelativePos);

VideoPlay_API float __stdcall VideoPlay_GetPlayPos(LONG nPort);

VideoPlay_API BOOL __stdcall VideoPlay_SetFileEndMsg(LONG nPort,HWND hWnd,UINT nMsg);

VideoPlay_API BOOL __stdcall VideoPlay_SetVolume(LONG nPort,WORD nVolume);

VideoPlay_API BOOL __stdcall VideoPlay_StopSound();

VideoPlay_API BOOL __stdcall VideoPlay_PlaySound(LONG nPort);

VideoPlay_API BOOL __stdcall VideoPlay_OpenStream(LONG nPort,PBYTE pFileHeadBuf,DWORD nSize,DWORD nBufPoolSize);

VideoPlay_API BOOL __stdcall VideoPlay_OpenStreamEx(LONG nPort,PBYTE pFileHeadBuf,DWORD nSize,DWORD nBufPoolSize, int iMaxImageWidth, int iMaxImageHeight);

VideoPlay_API BOOL __stdcall VideoPlay_InputData(LONG nPort,PBYTE pBuf,DWORD nSize);

VideoPlay_API BOOL __stdcall VideoPlay_CloseStream(LONG nPort);

VideoPlay_API int  __stdcall VideoPlay_GetCaps();

VideoPlay_API DWORD __stdcall VideoPlay_GetFileTime(LONG nPort);

VideoPlay_API DWORD __stdcall VideoPlay_GetPlayedTime(LONG nPort);

VideoPlay_API DWORD __stdcall VideoPlay_GetAbsoluteTime(LONG nPort);

VideoPlay_API BOOL __stdcall VideoPlay_ChangeContrast(LONG nPort,int degree);

VideoPlay_API BOOL __stdcall VideoPlay_ChangeBright(LONG nPort,int degree);

VideoPlay_API BOOL _stdcall VideoPlay_LocalZoom(LONG nPort,BOOL bLocalZoom,int Left,int Top,int Width,int Height);

VideoPlay_API BOOL __stdcall VideoPlay_SetDecCallBack(LONG nPort,void (CALLBACK* DecCBFun)(long nPort,char * pBuf,long nSize,FRAME_INFO * pFrameInfo, long nReserved1,long nReserved2));

VideoPlay_API BOOL __stdcall VideoPlay_SetDecCallBackUser(LONG nPort,void (CALLBACK* DecCBFun)(long nPort,char * pBuf,long nSize,FRAME_INFO * pFrameInfo, long lUser,long nReserved2), long lUser);

VideoPlay_API BOOL __stdcall VideoPlay_SetDisplayCallBack(LONG nPort,void (CALLBACK* DisplayCBFun)(long nPort,char * pBuf,long nSize,long nWidth,long nHeight,long nStamp,long nType,long nReserved));

VideoPlay_API BOOL __stdcall VideoPlay_SnapBMP(LONG nPort, PBYTE pBuf,long* nSize,long* nWidth,long* nHeight,long* nType );

VideoPlay_API BOOL __stdcall VideoPlay_ConvertToBmpFile(char * pBuf,long nSize,long nWidth,long nHeight,long nType,char *sFileName);

VideoPlay_API DWORD __stdcall	VideoPlay_GetFileTotalFrames(LONG nPort);

VideoPlay_API DWORD __stdcall	VideoPlay_GetCurrentFrameRate(LONG nPort);

VideoPlay_API DWORD __stdcall	VideoPlay_GetPlayedTimeEx(LONG nPort);

VideoPlay_API BOOL __stdcall VideoPlay_SetPlayedTimeEx(LONG nPort,DWORD nTime);

VideoPlay_API DWORD __stdcall	VideoPlay_GetCurrentFrameNum(LONG nPort);

VideoPlay_API BOOL __stdcall VideoPlay_SetStreamOpenMode(LONG nPort,DWORD nMode);

VideoPlay_API DWORD __stdcall	VideoPlay_GetFileHeadLength();

VideoPlay_API DWORD __stdcall	VideoPlay_GetSdkVersion();

VideoPlay_API DWORD __stdcall VideoPlay_GetLastError(LONG nPort);

VideoPlay_API BOOL __stdcall VideoPlay_RefreshPlay(LONG nPort);

VideoPlay_API BOOL __stdcall VideoPlay_SetOverlayMode(LONG nPort,BOOL bOverlay,COLORREF colorKey);

VideoPlay_API BOOL __stdcall VideoPlay_GetPictureSize(LONG nPort,LONG *pWidth,LONG *pHeight);

VideoPlay_API BOOL __stdcall VideoPlay_SetPicQuality(LONG nPort,BOOL bHighQuality);

VideoPlay_API BOOL __stdcall VideoPlay_PlaySoundShare(LONG nPort);

VideoPlay_API BOOL __stdcall VideoPlay_StopSoundShare(LONG nPort);

VideoPlay_API BOOL __stdcall VideoPlay_WaterMarkIsRight(LONG nPort);

VideoPlay_API LONG __stdcall VideoPlay_GetOverlayMode(LONG nPort);

VideoPlay_API COLORREF __stdcall VideoPlay_GetColorKey(LONG nPort);

VideoPlay_API WORD __stdcall VideoPlay_GetVolume(LONG nPort);

VideoPlay_API BOOL __stdcall VideoPlay_GetPictureQuality(LONG nPort,BOOL *bHighQuality);

VideoPlay_API DWORD __stdcall VideoPlay_GetSourceBufferRemain(LONG nPort);

VideoPlay_API BOOL __stdcall VideoPlay_ResetSourceBuffer(LONG nPort);

VideoPlay_API BOOL __stdcall VideoPlay_SetSourceBufCallBack(LONG nPort,DWORD nThreShold,void (CALLBACK * SourceBufCallBack)(long nPort,DWORD nBufSize,DWORD dwUser,void*pResvered),DWORD dwUser,void *pReserved);

VideoPlay_API BOOL __stdcall VideoPlay_ResetSourceBufFlag(LONG nPort);

VideoPlay_API BOOL __stdcall VideoPlay_SetDisplayBuf(LONG nPort,DWORD nNum);

VideoPlay_API DWORD __stdcall VideoPlay_GetDisplayBuf(LONG nPort);

VideoPlay_API BOOL __stdcall VideoPlay_OneByOneBack(LONG nPort);

VideoPlay_API BOOL __stdcall VideoPlay_SetFileRefCallBack(LONG nPort, void (__stdcall *pFileRefDone)(DWORD nPort,DWORD nUser),DWORD nUser);

VideoPlay_API BOOL __stdcall VideoPlay_SetCurrentFrameNum(LONG nPort,DWORD nFrameNum);

VideoPlay_API BOOL __stdcall VideoPlay_GetKeyFramePos(LONG nPort,DWORD nValue, DWORD nType, PFRAME_POS pFramePos);

VideoPlay_API BOOL __stdcall VideoPlay_GetNextKeyFramePos(LONG nPort,DWORD nValue, DWORD nType, PFRAME_POS pFramePos);

VideoPlay_API BOOL __stdcall VideoPlay_ThrowBFrameNum(LONG nPort,DWORD nNum);

VideoPlay_API BOOL _stdcall VideoPlay_SetPlaySpeed(LONG nPort,int nSpeed);

VideoPlay_API LONG __stdcall VideoPlay_GetStreamOpenMode(LONG nPort);

VideoPlay_API ULONG __stdcall VideoPlay_GetFilePos(LONG nPort);




//////////////////////////////////////////////////////////////////////////

 BOOL _stdcall DecoderOneFrame_MultiDecoder(HANDLE m_Handle , int BitCount, BYTE CodecType, int iWidth, int iHeight);

 BOOL _stdcall SetVideoFormat( int NewVideoFormat );

 BOOL _stdcall SetPostProcess( HANDLE m_Handle, BOOL IfPostProcess, int Flag = 0x3F );

 BOOL _stdcall TestIfNeedMMX();

 HANDLE _stdcall SDK_InitDecoder(unsigned char **DecoderInput , unsigned char **DecoderOutput , int PictureW , int PictureH, int nPort);

 BOOL _stdcall FreeDecoder( HANDLE m_CurHandle );

 BOOL _stdcall GetWH_MultiDecoder( HANDLE m_Handle , int *picWidth , int *picHeight, int *edge_size);

 BOOL _stdcall SetFlip( HANDLE m_Handle , BOOL IfFlip );

 BOOL _stdcall SetBright( HANDLE m_Handle , int NewBright );

 BOOL _stdcall SetContrast( HANDLE m_Handle , int NewContrast );

 unsigned char* _stdcall GetYUV( HANDLE m_Handle );

 BOOL _stdcall TransYUVtoRGB(HANDLE m_Handle );

 BOOL _stdcall GetThrowBNum( HANDLE m_Handle , int num);

 BOOL _stdcall SetBFrameType( HANDLE m_Handle , int type );

 BOOL __stdcall ConvertBMPtoBuf(PBYTE pBuf,long* nSize,long* nWidth,long* nHeight,long* nType);

 BOOL _stdcall CheckWaterMarkData( HANDLE m_Handle );
//////////////////////////////////////////////////////////////////////////


VideoPlay_API BOOL __stdcall VideoPlay_SetAudioCallBack(LONG nPort, void (__stdcall * funAudio)(long nPort, char * pAudioBuf, long nSize, long nStamp, long nType, long nUser), long nUser);

VideoPlay_API BOOL __stdcall VideoPlay_RigisterDrawFun(LONG nPort,void (CALLBACK* DrawFun)(long nPort,HDC hDc,LONG nUser),LONG nUser);

VideoPlay_API BOOL __stdcall VideoPlay_RigisterDrawFun_Ex(LONG nPort,void (CALLBACK* DrawFunEx)(long nPort,HDC hDc,LONG nUser),LONG nUser);

VideoPlay_API BOOL __stdcall VideoPlay_SetDisplayRegion(LONG nPort,DWORD nRegionNum, RECT *pSrcRect, HWND hDestWnd, BOOL bEnable);

VideoPlay_API BOOL __stdcall VideoPlay_GetRefValue(LONG nPort,BYTE *pBuffer, DWORD *pSize);

VideoPlay_API BOOL __stdcall VideoPlay_SetRefValue(LONG nPort,BYTE *pBuffer, DWORD nSize);

VideoPlay_API BOOL __stdcall VideoPlay_SetEncChangeMsg(LONG nPort,HWND hWnd,UINT nMsg);

VideoPlay_API BOOL __stdcall VideoPlay_SetEncTypeChangeCallBack(LONG nPort,void(CALLBACK *funEncChange)(long nPort,long nUser),long nUser);

VideoPlay_API BOOL __stdcall VideoPlay_SetColor(LONG nPort, DWORD nRegionNum, int nBrightness, int nContrast, int nSaturation, int nHue);

VideoPlay_API BOOL __stdcall VideoPlay_GetColor(LONG nPort, DWORD nRegionNum, int *pBrightness, int *pContrast, int *pSaturation, int *pHue);

VideoPlay_API BOOL __stdcall VideoPlay_SetDecCBStream(LONG nPort,DWORD nStream);

VideoPlay_API BOOL __stdcall VideoPlay_GetOriginalFrameCallBack(LONG nPort, BOOL bIsChange,
														   BOOL bNormalSpeed,long nStartFrameNum,long nStartStamp,long nFileHeader,
														   void(CALLBACK *funGetOrignalFrame)(long nPort,FRAME_TYPE *frameType, 
														   long nUser),long nUser);

VideoPlay_API BOOL __stdcall VideoPlay_GetFileSpecialAttr(LONG nPort, DWORD *pTimeStamp,
														DWORD *pFileNum ,DWORD *nFileHeader);

VideoPlay_API BOOL __stdcall VideoPlay_SetDisplayType(LONG nPort,LONG nType);

VideoPlay_API long __stdcall VideoPlay_GetDisplayType(LONG nPort);

#endif
